<template>
  <div class="nav-conntainer">
    <div
      class="item"
      v-for="(item, index) in data && data.length ? data : defaultData"
      :key="index"
    >
      <div class="item-text">
        <div class="status-text">{{ getStatusTxt(item) }}</div>
        <div class="progress-date">{{ item.date }}</div>
      </div>

      <div class="progress-container">
        <div
          class="bar"
          :class="{ no: item.status === '4' }"
          :style="{ width: item.progress || 0 }"
        ></div>
      </div>
      <div class="precess-icon" :class="getClass(item, index)"></div>
      <div
        class="name-container"
        :class="
          item.status === '1'
            ? 'name-bg-default'
            : item.status === '4'
            ? 'name-bg-no'
            : 'name-bg'
        "
      >
        {{ item.name }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "process-list",
  props: {
    data: [],
  },
  data() {
    return {
      defaultData: [
        {
          name: "上线评审",
          status: "3", //1未开始 2进行中  3 提前完成 4 超时
          date: "", //提前完成或超时时间
          progress: "0", //该阶段完成百分比
        },
        {
          name: "交付详情",
          status: "3", //1未开始 2进行中  3 提前完成 4 超时
          date: "05:36", //提前完成或超时时间
          progress: "100%", //该阶段完成百分比
        },
        {
          name: "提前批次",
          status: "3", //1未开始 2进行中  3 提前完成 4 超时
          date: "05:36", //提前完成或超时时间
          progress: "100%", //该阶段完成百分比
        },
        {
          name: "主体批次",
          status: "4", //1未开始 2进行中  3 提前完成 4 超时
          date: "05:36", //提前完成或超时时间
          progress: "100%", //该阶段完成百分比
        },
        {
          name: "测试实施",
          status: "2", //1未开始 2进行中  3 提前完成 4 超时
          date: "05:36", //提前完成或超时时间
          progress: "1%", //该阶段完成百分比
        },
        {
          name: "次日交接",
          status: "1", //1未开始 2进行中  3 提前完成 4 超时
          date: "", //提前完成或超时时间
          progress: "", //该阶段完成百分比
        },
      ],
    };
  },
  created() {},
  methods: {
    getClass(item, index) {
      let status = "";
      switch (item.status) {
        case "1":
          status = "un";
          break;
        case "2":
          status = "un";
          break;
        case "3":
          status = "do";
          break;
        case "4":
          status = "no";
          break;
      }
      return `process${index + 1}-${status}`;
    },
    getStatusTxt(item) {
      let status = "";
      switch (item.status) {
        case "1":
          status = "";
          break;
        case "2":
          status = "倒计时";
          break;
        case "3":
          status = "提前完成";
          break;
        case "4":
          status = "超时";
          break;
      }
      return status;
    },
  },
};
</script>
<style>
@font-face {
  font-family: "NumberFont";
  src: url("./images/庞门正道标题体2.0增强版.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: "NameFont";
  src: url("./images/优设标题黑.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
}
</style>
<style scoped>
.nav-conntainer {
  background: #08163b;
  display: flex;
  justify-content: space-between;
  padding: 20px 0;
  height: 166px;
  margin: 0 -70px;
}
.nav-conntainer .item {
  flex: 1;
  position: relative;
}

.nav-conntainer .item:nth-of-type(1) .item-text,
.nav-conntainer .item:nth-of-type(1) .progress-container {
  display: none;
}
.precess-icon {
  width: 162px;
  height: 130px;
  position: absolute;
  left: 50%;
  margin-left: -81px;
  z-index: 9;
}
.process1-un {
  background: url("./images/process1-un.png") no-repeat;
}
.process1-do {
  background: url("./images/process1-do.png") no-repeat;
}
.process1-no {
  background: url("./images/process1-no.png") no-repeat;
}
.process2-un {
  background: url("./images/process2-un.png") no-repeat;
}
.process2-do {
  background: url("./images/process2-do.png") no-repeat;
}
.process2-no {
  background: url("./images/process2-no.png") no-repeat;
}
.process3-un {
  background: url("./images/process3-un.png") no-repeat;
}
.process3-do {
  background: url("./images/process3-do.png") no-repeat;
}
.process3-no {
  background: url("./images/process3-no.png") no-repeat;
}
.process4-un {
  background: url("./images/process4-un.png") no-repeat;
  background-position: 0 5px;
}
.process4-do {
  background: url("./images/process4-do.png") no-repeat;
  background-position: 0 5px;
}
.process4-no {
  background: url("./images/process4-no.png") no-repeat;
  background-position: 0 5px;
}
.process5-un {
  background: url("./images/process5-un.png") no-repeat;
}
.process5-do {
  background: url("./images/process5-do.png") no-repeat;
}
.process5-no {
  background: url("./images/process5-no.png") no-repeat;
}
.process6-un {
  background: url("./images/process6-un.png") no-repeat;
  background-position: 0 5px;
}
.process6-do {
  background: url("./images/process6-do.png") no-repeat;
  background-position: 0 5px;
}
.process6-no {
  background: url("./images/process6-no.png") no-repeat;
  background-position: 0 5px;
}

.item-text {
  position: absolute;
  left: 0;
  top: 36px;
  left: -36px;
  text-align: center;
}
.status-text {
  color: #56b9ff;
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 2px;
}
.progress-date {
  font-family: "NumberFont", sans-serif;
  color: #56b9ff;
  font-size: 20px;
  font-weight: bold;
  background: -webkit-linear-gradient(bottom, #52bfff, #dbf2ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.name-container {
  font-family: "NameFont", sans-serif;
  width: 126px;
  height: 44px;
  line-height: 44px;
  color: #fff;
  font-size: 26px;
  position: absolute;
  bottom: 0;
  left: 50%;
  margin-left: -64px;
  text-align: center;
  z-index: 12;
  letter-spacing: 2px;
}
.name-bg {
  background: url("./images/do-text-bg.png") no-repeat;
}
.name-bg-default {
  background: url("./images/defulat-text-bg.png") no-repeat;
}
/* 红色背景 */
.name-bg-no {
  background: url("./images/no-text-bg.png") no-repeat;
}
.progress-container {
  height: 20px;
  width: 77%;
  background: url("./images/default-line.png") no-repeat;
  left: -50%;
  position: absolute;
  top: 100px;
  margin-left: 38px;
}
.progress-container .bar {
  width: 100%;
  height: 20px;
  background: url("./images/do-line.png") no-repeat;
  background-size: auto;
}
.progress-container .bar.no {
  background: url("./images/no-line.png") no-repeat;
}
</style>
